const http = uni.$u.http

export default {
	/**
	 * 获取所有城市
	 *  - get请求
	 */
	getAllCityAPI: () => {
		return http.get('/city', {
			custom: {
				// 隐藏加载loading
				hideLoading: true
			}
		});
	},

	/**
	 * 添加地址
	 *  - post请求
	 */
	addAddressAPI: (data) => {
		return http.post('/address', data, {
			custom: {
				auth: true,
				toast: true
			}
		});
	},

	/**
	 * 设置默认地址
	 */
	setDefaultAddressAPI: (id) => {
		return http.post('/setDefault/' + id, {}, {
			custom: {
				auth: true,
				hideLoading: true
			}
		});
	},

	/**
	 * 获取自己的地址列表
	 *  - get请求
	 */
	getAddressAPI: (hideLoading = false) => {
		return http.get('/address', {
			custom: {
				auth: true,
				hideLoading
			}
		});
	},

	/**
	 * 获取默认地址
	 *  - get请求
	 */
	getDefaultAddressAPI: (hideLoading = false) => {
		return http.get('/defalutAddress', {
			custom: {
				auth: true,
				hideLoading
			}
		});
	},

	/**
	 * 根据地址ID获取详细信息
	 *  - get请求
	 */
	getAddressByIdAPI: (id) => {
		return http.get('/address/' + id, {
			custom: {
				auth: true
			}
		});
	},

	/**
	 * 更新地址信息
	 *  - put请求
	 */
	updateAddressAPI: (id, data) => {
		return http.put('/address/' + id, data, {
			custom: {
				auth: true,
				toast: true
			}
		});
	},

	/**
	 * 删除地址
	 *  - delete请求
	 */
	deleteAddressAPI: (id) => {
		return http.delete('/address/' + id, {}, {
			custom: {
				auth: true,
				toast: true
			}
		});
	}
}